import os

from aiogram.enums import ContentType
from aiogram_dialog import DialogManager
from aiogram_dialog.api.entities import MediaAttachment
from fluentogram import TranslatorRunner

from weed_shop.core.constants import ASSETS_FOLDER


async def google_maps_asset_getter(dialog_manager: DialogManager, locale: TranslatorRunner, **kwargs):
    google_maps_video = None
    try:
        if os.path.isfile(file_path := os.path.join(ASSETS_FOLDER, f"google_maps_{locale.translators[0].locale}.mp4")):
            google_maps_video = MediaAttachment(
                path=file_path,
                type=ContentType.DOCUMENT,
            )
    except TypeError:
        pass
    return {"google_maps_video": google_maps_video}


async def phone_asset_getter(dialog_manager: DialogManager, **kwargs):
    phone_hint_video = None
    try:
        if os.path.isfile(file_path := os.path.join(ASSETS_FOLDER, f"phone_hint.mp4")):
            phone_video = MediaAttachment(
                path=file_path,
                type=ContentType.DOCUMENT,
            )
    except TypeError:
        pass
    return {"phone_hint_video": phone_hint_video}


async def name_asset_getter(dialog_manager: DialogManager, **kwargs):
    name_hint_video = None
    try:
        if os.path.isfile(file_path := os.path.join(ASSETS_FOLDER, f"name_hint.mp4")):
            name_hint_video = MediaAttachment(
                path=file_path,
                type=ContentType.DOCUMENT,
            )
    except TypeError:
        pass
    return {"name_hint_video": name_hint_video}
